cmake_minimum_required(VERSION 2.6)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)

project(dev)

# find library
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})

if (WINDOWS)
add_definitions(-D__WINDOWS__)
add_definitions(-D_WIN32_WINNT=0x0501)
add_definitions(-D_USE_SELECT)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS)
else ()
add_definitions(-D__LINUX__)
add_definitions(-D_USE_EPOLL)
	if (CMAKE_COMPILER_IS_GNUCXX)
	add_definitions(-std=gnu++0x)
	else ()
	add_definitions(-std=stdc++11)
	endif()
endif()

if (DEBUG)
add_definitions(-D_DEBUG)
endif()

set(dev_SOURCES
	dev/Dev.hpp
	dev/Platform.hpp
	dev/base/Console.hpp
	dev/base/Base.hpp
	dev/base/Atomic.hpp
	dev/base/Runtime.hpp
	dev/base/Logger.hpp
	src/base/Logger.cpp
	dev/base/Mutex.hpp
	dev/base/LockGuard.hpp
	dev/base/Exception.hpp
	src/base/Exception.cpp
	dev/base/Thread.hpp
	src/base/Thread.cpp
	dev/base/Mutex.hpp
	dev/base/LockedQueue.hpp
	dev/base/LockedMap.hpp
	dev/base/TimeUtil.hpp
	src/base/TimeUtil.cpp
	dev/base/detail/ConfigFile.hpp
	dev/base/detail/IniConfigFile.hpp
	dev/base/detail/XmlConfigFile.hpp
	
	dev/net/Net.hpp
	dev/net/SocketApi.hpp
	dev/net/Socket.hpp
	src/net/Socket.cpp
	dev/net/SocketEventHandler.hpp
	dev/net/Reactor.hpp
	dev/net/detail/SelectReactor.hpp
	src/net/detail/SelectReactor.cpp
	dev/net/EventLoop.hpp
	src/net/EventLoop.cpp
	dev/net/TcpConnectionStream.hpp
	dev/net/TcpConnectionInputStream.hpp
	dev/net/TcpConnectionOutputStream.hpp
	src/net/TcpConnectionStream.cpp
	src/net/TcpConnectionInputStream.cpp
	src/net/TcpConnectionOutputStream.cpp
	dev/net/TcpConnection.hpp
	src/net/TcpConnection.cpp
	dev/net/TcpConnectionFactory.hpp
	dev/net/TcpAcceptor.hpp
	src/net/TcpAcceptor.cpp
	dev/net/TcpWorker.hpp
	src/net/TcpWorker.cpp
	dev/net/TcpServer.hpp
	src/net/TcpServer.cpp
)

if (WINDOWS)
set(plat_SRC
)
else()
set(plat_SRC
	dev/net/detail/EPollReactor.hpp
	src/net/detail/EPollReactor.cpp
)
endif()

if (WINDOWS)
include_directories( 
	${PROJECT_SOURCE_DIR}
)
else ()
include_directories(
	${PROJECT_SOURCE_DIR}
)
endif()

add_library(dev STATIC ${dev_SOURCES} ${plat_SRC})
